package com.hzhk.happyrent.ui.holder.card;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.LayoutAnimationController;
import android.view.animation.TranslateAnimation;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.google.gson.Gson;
import com.hzhk.happyrent.R;
import com.hzhk.happyrent.bean.rent.TypesModel;
import com.hzhk.happyrent.network.API;
import com.hzhk.happyrent.network.HttpManager;
import com.hzhk.happyrent.ui.activity.YuyueCardActivity;
import com.hzhk.happyrent.ui.adapter.card.CardFunctionAdapter;
import com.hzhk.happyrent.ui.adapter.card.CardThemeAdapter;


import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by soft_zzc on 2017/11/24.
 */

public class CardThemeViewHolder {

    @BindView(R.id.card_theme_handle_card)
    LinearLayout cardThemeHandleCard;
    @BindView(R.id.card_theme_search)
    LinearLayout cardThemeSearch;
    @BindView(R.id.card_theme_strategy)
    LinearLayout cardThemeStrategy;
    @BindView(R.id.card_theme_paihang)
    LinearLayout cardThemePaihang;
    @BindView(R.id.card_theme_tuijian)
    LinearLayout cardThemeTuijian;
    @BindView(R.id.card_theme_new)
    LinearLayout cardThemeNew;
    @BindView(R.id.card_theme_jisu)
    LinearLayout cardThemeJisu;
    @BindView(R.id.card_top_li)
    LinearLayout cardTopLi;

    private CardFunctionAdapter cardFunctionAdapter;
    private CardThemeAdapter cardThemeAdapter;
    private Context context;

    public CardThemeViewHolder(View convertView, Context context) {
        this.context = context;
        ButterKnife.bind(this, convertView);
        initView();
        initData();
    }





    public void setAction() {
//        initData();
//		home_function_gv.setLayoutAnimation(getAnimationController());
//        homeFunctionAdapter.setList();
    }

    private void initData() {
       /* Map<String,String> map=new HashMap<>();
        map.put("seat","2");
        HttpManager.getInstance().get(API.TYPES, map, new RxStringCallback() {
            @Override
            public void onError(Object tag, Throwable e) {
                Toast.makeText(context,e.getMessage(),Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onCancel(Object tag, Throwable e) {

            }

            @Override
            public void onNext(Object tag, String response) {
                TypesModel typesModel=new Gson().fromJson(response,TypesModel.class);
                cardFunctionAdapter.setList(typesModel);

            }
        });*/
    }

  /*  private LayoutAnimationController getAnimationController() {
        int duration = 250;
        AnimationSet set = new AnimationSet(true);
        Animation animatable = new AlphaAnimation(0.0f, 1.0f);
        animatable.setDuration(duration);
        set.addAnimation(animatable);

        animatable = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f
                , Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        animatable.setDuration(duration);
        set.addAnimation(animatable);
        LayoutAnimationController controller = new LayoutAnimationController(set, 0.2f);
        controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
        return controller;
    }
*/
    private void initView() {

        cardThemeHandleCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.startActivity(new Intent(context, YuyueCardActivity.class));
            }
        });
        cardThemeSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        cardThemeStrategy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        cardThemePaihang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        cardThemeTuijian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        cardThemeNew.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        cardThemeJisu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();

            }
        });
        /*cardFunctionAdapter = new CardFunctionAdapter(context);
        cardThemeAdapter = new CardThemeAdapter(context);
        cardTopLi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(context,R.string.function_in_development,Toast.LENGTH_SHORT).show();
            }
        });*/

        // TODO: 2017/11/25 暂时不用数据展示
       /* rentTypeFunction.setAdapter(cardFunctionAdapter);
        cardThemeType.setAdapter(cardThemeAdapter);
        rentTypeFunction.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                                    long arg3) {
            }
        });
        cardThemeType.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int position,
                                    long arg3) {
            }
        });*/
    }
//
}
